﻿
package extremefx.ui.dnd {
	import extremefx.anim.Tween;
	import extremefx.drawing.screenShoot;
	import extremefx.ui.Component;
	import extremefx.ui.dnd.IDraggingImage;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;		

	/**
	 * @author Marcelo Volmaro
	 */
	public class DefaultDragImage implements IDraggingImage {
		private var _width:uint;
		private var _height:uint;
		private var _cmp:Component;
		private var _bmpData:BitmapData;
		private var _bmp:Bitmap;
		private var _tween:Tween;

		public function DefaultDragImage(pDragInitiator:Component){
			_width = pDragInitiator.width;
			_height = pDragInitiator.height;
			_cmp = pDragInitiator;
			_bmpData = screenShoot(pDragInitiator.sprite);
			_bmp = new Bitmap(_bmpData);
			_tween = new Tween(_bmp, .3);
		}
		
		public function get acceptImage():DisplayObject {
			_bmp.alpha = 1;
			_tween.setProperty("alpha", .7);

			return _bmp;
		}
		
		public function get rejectImage():DisplayObject {
			_bmp.alpha = 1;
			_tween.setProperty("alpha", .7);
			
			return _bmp;
		}
		
		public function dispose():void {
			_bmpData.dispose();
			_tween.dispose();
			_bmp = null;
		}
	}
}
